<?php
define('SETTINGS_FILE', 'set.php');
define('CREDENTIALS_FILE', 'sec.php');
/// Thanks 
function SpaceFormat($Wert) 
{
	if ($Wert > 1099511627776) {
		$Wert = number_format ( $Wert / 1099511627776, 2, ".", "," ) . " TB";
	} elseif ($Wert > 1073741824) {
		$Wert = number_format ( $Wert / 1073741824, 2, ".", "," ) . " GB";
	} elseif ($Wert > 1048576) {
		$Wert = number_format ( $Wert / 1048576, 2, ".", "," ) . " MB";
	} elseif ($Wert > 1024) {
		$Wert = number_format ( $Wert / 1024, 2, ".", "," ) . " kB";
	} else {
		$Wert = number_format ( $Wert, 2, ".", "," ) . " Bytes";
	}
	
	return $Wert;
}

/// Thanks freamer89
function write_ini_file($array, $file)
{
    $res = array();
    foreach($array as $key => $val)
    {
        if(is_array($val))
        {
            $res[] = "[$key]";
            foreach($val as $skey => $sval) $res[] = "$skey = ".(is_numeric($sval) ? $sval : '"'.$sval.'"');
        }
        else $res[] = "$key = ".(is_numeric($val) ? $val : '"'.$val.'"');
    }
    $security = "; <?php die()?>\r\n";
    file_put_contents($file, $security.implode("\r\n", $res));
}

function saveSettings($array)
{  
   write_ini_file($array, SETTINGS_FILE);
}

function loadSettings()
{
   return parse_ini_file(SETTINGS_FILE);
}

function loadCredentials()
{
   return parse_ini_file(CREDENTIALS_FILE);
}

function saveCredentials($array)
{
   write_ini_file($array, CREDENTIALS_FILE);
}

function getTitle()
{
   return 'dGetter';
}
?>
